package com.bokee.archerwq.lab.twhomework;

import junit.framework.Assert;

import org.junit.Test;

/**
 * Test cases for Rover & Plateau
 * 
 * @author Johnny 2012-8-1
 * 
 */
public class MarsRoverTest {

	@Test
	public void case1() throws BadCommandException {
		Plateau plateau = new Plateau(5, 5);
		Rover rover = new Rover(1, 2, 'N');
		rover.navigate("LMLMLMLMM", plateau);
		Assert.assertEquals(1, rover.getCoordinateX());
		Assert.assertEquals(3, rover.getCoordinateY());
		Assert.assertEquals('N', rover.getHeading());
	}

	@Test
	public void case2() throws BadCommandException {
		Plateau plateau = new Plateau(5, 5);
		Rover rover = new Rover(3, 3, 'E');
		rover.navigate("MMRMMRMRRM", plateau);
		Assert.assertEquals(5, rover.getCoordinateX());
		Assert.assertEquals(1, rover.getCoordinateY());
		Assert.assertEquals('E', rover.getHeading());
	}

	@Test(expected = BadCommandException.class)
	public void case_badcommand() throws BadCommandException {
		Plateau plateau = new Plateau(5, 5);
		Rover rover = new Rover(3, 3, 'E');
		rover.navigate("MMRMMRMRRMRMM", plateau);
	}

}
